/*长连接测试1: 创建一个客户端持续给服务器发送数据，直到超过时间看是否正常*/
#include "../include/socket.h"
#include "../include/logger.h"
#include <iostream>
#include <cassert>
#include <string>
 
int main()
{
    std::cout << "Testing Connection: keep-alive..." << std::endl;
    const std::string logFile = "test_long_connection";
    util::Logger::instance().init(logFile, 1024*1024, 1);
    util::Logger::instance().setLevel(util::LogLevel::INFO);

    net::Socket clientSock;
    clientSock.createClient(8081, "127.0.0.1");
    std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
    while (1)
    {
        assert(clientSock.send(req.c_str(), req.size()) != -1);
        char buf[1024] = {0};
        assert(clientSock.recv(buf, 1023));
        LOG_INFO("%s", buf);
        sleep(3);
    }
    clientSock.close();
    return 0;
}